package iterator;

import lombok.AllArgsConstructor;

import java.util.Iterator;
import java.util.List;

/**
 * @author Fengdong.Duan
 * @create 2023/11/24 16:34
 */
@AllArgsConstructor
public class OutPutImpl {
    List<College> colleges;

    /**
     * 遍历所有学院
     */
    public void printCollege() {
        Iterator<College> iterator = colleges.iterator();
        while (iterator.hasNext()) {
            College college = iterator.next();
            System.out.println(college.getName());
            printDepartment(college.createIterator());
        }
    }

    public void printDepartment(Iterator<Department> iterator) {
        while (iterator.hasNext()) {
            Department next = iterator.next();
            System.out.println(next);
        }
    }

}
